package org.changchen.fgt.controller.admin;

import org.changchen.fgt.dto.ApiResult;
import org.changchen.fgt.dto.LiveChannelProcess;
import org.changchen.fgt.service.LiveChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping(value = "/admin/live")
public class LiveSourceController {
	
	
		@Autowired
		private LiveChannelService liveChannelService;
		
		
		@GetMapping(value = {""})
		public ModelAndView live() {
			ModelAndView model = new ModelAndView("admin/live_source");
			return model;
		}
	
	
		@PostMapping(value = "/add")
		@ResponseBody
		public ApiResult<Boolean> addChannel(@RequestParam("file") MultipartFile file){
			liveChannelService.addLiveChannel(file);
			return ApiResult.success(true);
		}
		
		
		@GetMapping(value = "/add/process")
		@ResponseBody
		public LiveChannelProcess getAddProcess(Long key) {
			return liveChannelService.getHandleProcess(key);
		}
	

}
